#pragma once

/*
 * @Author: hzm 
 * @Date: 2020-06-08 20:25:14 
 * @Last Modified by: hzm
 * @Last Modified time: 2020-06-11 23:06:46
 */

#include <memory>
#include <map>
#include <vector>

#include "MysqlDB.h"
#include "DBStruct.h"

#define MAXCMDLEN 8192

class MysqlManager
{
public:
    MysqlManager();
    ~MysqlManager();

public:
    bool init(const char* host, const char* user, const char* pwd, const char* dbname);

	std::string getHost() { return m_strHost; }
	std::string getUser() { return m_strUser; }
	std::string getPwd() { return m_strPassword; }
	std::string getDBName() { return m_strDataBase; }
	std::string getCharSet() { return m_strCharactSet;  }

private:
	bool isDBExist();
	bool createDB();
	bool checkTable(const STableInfo& table);
	bool createTable(const STableInfo& table);
	bool updateTable(const STableInfo& table);

protected:
	std::shared_ptr<MysqlDB>            m_poConn;

    std::string                         m_strHost;
    std::string                         m_strUser;
    std::string                         m_strPassword;
    std::string                         m_strDataBase;
    std::string                         m_strCharactSet;

	std::vector<STableInfo>             m_vecTableInfo;
};